import {defHttp} from '/@/utils/http/axios';
import {ProjectInfo} from "/@/api/project/model/projectModel";
import {BasicPageSearchParams} from "/@/api/model/baseModel";

// 项目管理->项目立项
enum Api {
  list = '/CheckProject/list',
  view = '/CheckProject/view/',
  add = '/CheckProject/add',
  del = '/CheckProject/del/',
  update = '/CheckProject/update',
  getAll = '/CheckProject/getAll/',
}


/**
 * @description: 项目列表下拉框接口
 */
export const getAll = (params?: Recordable) =>
  defHttp.get<Recordable[]>({ url: Api.getAll, params });

export const list = (params?: any) => {
  const query = params && { pageNum: params.pageNum, pageSize: params.pageSize };
  let entity = params || {};
  if (entity) {
    delete entity['pageNum'];
    delete entity['pageSize'];
  }
  const queryParam = { query, entity } as BasicPageSearchParams<any>;
  return defHttp.post<any>({ url: Api.list, params: queryParam });
};

export const view = (id?: number) => {
  return defHttp.get<any>({ url: Api.view + id });
};

export const add = (params?: ProjectInfo) =>
  defHttp.post<ProjectInfo>({url: Api.add, params});

export const update = (params?: ProjectInfo) =>
  defHttp.post<ProjectInfo>({url: Api.update, params});

export const del = (id?: number) =>
  defHttp.post<any>({ url: Api.del + id });
